package com.helmlabs.grouper.finance.dao;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.helmlabs.grouper.core.dao.GenericDaoHibernate;
import com.helmlabs.grouper.finance.model.Billable;

public class BillableDaoHibernate extends GenericDaoHibernate<Billable, Long> implements BillableDao  {
	
	public BillableDaoHibernate(){
		super(Billable.class);
	}

	public List<Billable> getAllUpaidBillablesByUserId(Long id) {
		log.debug("loading all the unpaid bills for the user id " + id);
		DetachedCriteria criteria = DetachedCriteria.forClass(Billable.class);
		criteria.add(Restrictions.eq("billedToUserId", id));
		criteria.add(Restrictions.eq("paid", false));
		return getHibernateTemplate().findByCriteria(criteria);
	}


}
